<?php
/* QQ:34734852
 * 业务联系：小鱼
 */
class strcode{
	
	public function __call( $FunName, $Prames ) {
		list( $String) = $Prames;
		switch( strtolower($FunName) ){
			case 'bin' : return $this -> txtbin( $String); break;
			default:     return $this -> bintxt( $String );
		}
	}
	
	
	private function txtbin( $str ) {
		$Val = unpack('H*', $str );
		$b   = '';
		foreach( str_split( $Val[1] ) as $v ) {
			$b .= str_pad(base_convert( $v, 16, 2), 4, '0', STR_PAD_LEFT);
		}
		unset( $Val, $v );
		return $b;
	}
	
	private function bintxt( $Str ) {
		$Bin = '';
		foreach( str_split( $Str, 4 ) as $v ) {
			$Bin .= base_convert( $v, 2, 16);
		}
		$Bin = pack('H*', $Bin );
		unset( $v );
		return $Bin;
	}
	
	
}